#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n1,n2;
    int temp;
    vector<int> a1;
    vector<int> a2;
    vector<int> a3;
    cin>>n1;
    for(int i = 0; i<n1; i++)
    {
        cin>> temp;
        a1.push_back(temp);
    }
    
    cin>>n2;
    for(int i = 0; i<n2; i++)
    {
        cin>> temp;
        a2.push_back(temp);
    }

    auto it1 = a1.begin();

    auto it2 = a2.begin();
    while(true)
    {
        if(it1 != a1.end())
        {
            auto cur1 =*it1;
            if(find(a2.begin(),a2.end(),cur1) != a2.end())
                 a3.push_back(*it1);
            it1++;
        } 
        if(it2 != a2.end())
        {
            auto cur2 =*it2;
            if(find(a1.begin(),a1.end(),cur2) != a1.end())
                a3.push_back(*it2);
            it2++;
        } 
        if(it1 == a1.end() && it2== a2.end())
           break;
    }
    int i;
    for(i = 0; i<a3.size(); i++)
        cout<<a3[i]<< " ";
    cout<<a3[i];
}